<template>
	<div class="article">
		<!-- <img :src="imgSrc"> -->
		<article>
			<h1>{{NewsDetailData.title}}</h1>
			<h5 class="release"><span>发布时间: {{NewsDetailData.releaseDate}}</span><span>发布人: {{NewsDetailData.author}}</span></h5>
			<div class="article_con" v-html="NewsDetailData.content" ref="articleCon"></div>
		</article>
	</div>
</template>
<script type="text/javascript">
	import getInterface from '../../assets/js/insterface'
	import PreviewImg from '../../assets/js/previewImg'

	export default{
		data(){
			return{
				imgSrc:'',
				NewsDetailData:[],
				NewsDetailUrl:getInterface.getNewsDetailUrl
			}
		},
		mixins:[PreviewImg],
		mounted(){
			
			this.$el.parentElement.parentNode.style.background = '#fff';
			// document.title="新闻通告";
			let columnId = this.$route.query.columnId;
			switch(columnId){
				case '56':
					document.title="周报";
					break;
				case '57':
					document.title="重要政策";
					break;
				case '58':
					document.title="重要新闻";
					break;
				case '59':
					document.title="问卷调查";
					break;
				case '60':
					document.title="在线培训";
					break;
			}
			this.getNewsDetail();
			let vue = this;
			setTimeout(()=>{
				vue.readImgInfo();
			},1100)
		},
		methods:{
			setStyle(){
				var tds = this.$refs.articleCon.getElementsByTagName('td');
				for(let i =0 ; i< tds.length; i++ ){
					tds[i].style.borderWidth = '1px';
					tds[i].style.borderStyle = 'solid';
				}
				// console.log(typeof tds)
				// tds.map(function(){
				// 	this.setAttribute('style','border:solid 1px #ddd');
				// })
			},
			getNewsDetail(){
				var params = {id:this.$route.query.id,columnId:this.$route.query.columnId}
				this.$http.post(this.NewsDetailUrl,params,{emulateJSON: true})
				.then((response) => {
					console.log(response)
					this.NewsDetailData = response.data.newsData;
					this.imgSrc = response.data.newsData.attachList[0].attachmentUrl;
					//this.imgSrc="http://img4.imgtn.bdimg.com/it/u=2965812645,1180239355&fm=23&gp=0.jpg"
					this.$nextTick(function(){
						this.setStyle();
					});
					
				})
				.catch(function(response){
					console.log(response);
				})
			},
			getImg(){
				console.log(this);
				debugger;
				console.log(document.getElementsByTagName("img"));

			}
		}

	}
</script>
